/**
 * 
 */
package net.looker.data;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 新闻数据管理器
 * @author solosky
 *
 */
public class DataManager
{
	private static DataManager dataManager;
	private ArrayList<DataDriver> driverList;
	
	/**
	 * 构造函数
	 * 初始化对象
	 */
	public DataManager()
	{
		driverList = new ArrayList<DataDriver>();
	}
	/**
	 * 返回数据管理对象
	 * @param DataManager
	 */
	public synchronized static DataManager getInstance()
	{
		if (dataManager==null)
			dataManager = new DataManager();
		return dataManager;
	}
	
	/**
	 * 添加驱动
	 */
	public void addDataDriver(DataDriver dataDriver)
	{
		driverList.add(dataDriver);
	}

	/**
	 * 添加一条新闻，包括附件
	 */
	public boolean add(News news)
	{
		Iterator<DataDriver> it = driverList.iterator();
		while (it.hasNext())
			it.next().add(news);
		
		return true;
	}
	
	/**
	 * 删除一条新闻，包括附件
	 */
	public boolean delete(News news)
	{
		Iterator<DataDriver> it = driverList.iterator();
		while (it.hasNext())
			it.next().delete(news);
		
		return true;
	}

}
